package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/27 14:10
 * @description
 */
public class Code220 {
    public static void main(String[] args) {
        System.out.println(
            new Code220().containsNearbyAlmostDuplicate(new int[] {2147483647, -2147483647}, 1, 2147483647));
    }

    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
        int l = nums.length - 1;
        for (int i = 0; i <= l; i++) {
            for (int j = i + 1; j <= Math.min(i + k, l); j++) {
                if (Math.abs((long)nums[i] - nums[j]) - t <= 0) {
                    return true;
                }
            }
        }
        return false;
    }
}
